
//类
//定义一个Dog类
class Dog{
    public String name;
    public String color;
    public int age;

    public void barks(){
        System.out.println(name + "汪汪叫");
    }
    public void wag(){
        System.out.println(name + "摇尾巴");
    }
}

//定义一个Student类
class Student{
    public String name;
    public int age;

    //构造函数
    Student(){
    }
    Student(String name,int age){
        this.name = name;
        this.age = age;
    }
    public void setStudent(String name,int age){
        this.name = name;
        this.age = age;
    }

    public void printfStudent(){
        System.out.println("姓名" + this.name + "，年龄" + this.age);
    }

    public void useClass(){
        this.printfStudent();
    }

}

//权限，就地初始化，静态成员变量
class A{
    private int a = 0;  //就地初始化
    int b;  //默认权限default
    static int c;   //静态成员变量
    //成员方法
    public int getA() {
        return a;
    }
    //参数名和成员变量相同时，局部优先会自己给自己赋值，故需加this（指当前对象）
    public void setA(int a) {
        this.a = a;
    }
    public int getB() {
        return b;
    }
    public void setB(int b) {
        this.b = b;
    }
    public static int getC() {
        return c;
    }
    //静态成员变量使用，类名.静态成员变量名；静态成员方法也是差不多的使用方式
    public static void setC(int c) {
        A.c = c;
    }

}

//内部类
class outClass{
    int a;
    private int b;
    public static int c;
    public void aA(){}
    class inClass{
        int d;
        static int e;
        public static void bB(){
//            outClass.a = 1;    //内部类静态只能使用外部类的静态
            outClass.c = 5;
        }
        public void cC(){
            inClass inclass = new inClass();

        }
    }
}

public class Test {
    public static void main(String[] args) {
        Student student = new Student();
        student.setStudent("楠楠",6);
        student.useClass();
    }
    public static void main1(String[] args) {
        //实例化一个Dog类对象
        Dog dog = new Dog();
        dog.name = "旺财";
        dog.age = 2;
        dog.color = "白色";
        System.out.println("它的名字叫" + dog.name + "今年" + dog.age + "岁了，颜色是" + dog.color);
        dog.wag();
        dog.barks();
    }
}
